package uri.model.member;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import uri.model.MemberVO;

@Repository
public class MemberDAOImpl implements MemberDAO {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	public MemberVO login(MemberVO mvo){
		return sqlSessionTemplate.selectOne("member.login", mvo);
	}
	
	public void registerMember(MemberVO mvo) {
		sqlSessionTemplate.insert("member.registerMember", mvo);
	}
	
	public int idCheck(String id){
		return sqlSessionTemplate.selectOne("member.idCheck", id);
	}
	
	public int ssnCheck(String ssn){
		return sqlSessionTemplate.selectOne("member.ssnCheck", ssn);
	}
	
	public int checkPassword(String password){
		return sqlSessionTemplate.selectOne("member.ssnCheck", password);
	}
	
	public void deleteMember(String id){
		sqlSessionTemplate.delete("member.deleteMember", id);
	}
	
	public void updateMemberInfo(MemberVO mvo){
		sqlSessionTemplate.update("member.updateMemberInfo", mvo);
	}
	
	public String findPassword(String id){
		return sqlSessionTemplate.selectOne("member.findPassword", id);
	}
	
	public String findId(String ssn){
		return sqlSessionTemplate.selectOne("member.findId", ssn);
	}
	
	public void updateMemberPassword(MemberVO mvo){
		sqlSessionTemplate.update("member.updateMemberPassword", mvo);
	}
	
	public List<MemberVO> getAllMemberList(){
		return sqlSessionTemplate.selectList("member.getAllMemberList");	
	}

	public List<MemberVO> findMember(HashMap<String, String> map) {
		return sqlSessionTemplate.selectList("member.findMember",map);
	}
	
	public void removeMember(String id){
		sqlSessionTemplate.delete("member.removeMember", id);
	}

	@Override
	public String findIdCheck(MemberVO mvo) {
		return sqlSessionTemplate.selectOne("member.findIdCheck",mvo);
	}

	@Override
	public String findPasswordCheck(MemberVO mvo) {
		return sqlSessionTemplate.selectOne("member.findPasswordCheck", mvo);
	}

}
